<?php
/*
 * notes:
 *   this tpl master main module and submodule grids
 *
 * if clone as another one, below tags need to be replace to ur target module tag
 * "clean_up_qc_form"
*/
?>
<div id="<?php echo WacModuleHelper::getListingTableId($invokeParams['moduleName'],$invokeParams['attachName']);?>">

    <div style="font-size:12px;"></div>
    <br />

    <table id="<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>"></table>
    <div id="<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>" ></div>

    <script type="text/javascript">
        //<![CDATA[
        jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid({
            datatype: "json",
            url: BASE_URL+"<?php echo $invokeParams['moduleName']; ?>/<?php echo $invokeParams['method']; ?>",
            editurl: "<?php echo $invokeParams['moduleName']; ?>/doOperation",
            postData: {dataFormat: "json"},
            colNames:['id', '编号', '生产单编号', '出仓单编号', '布幅', '匹长', '包装膜', '等级', '验收标准', '匹条', '百家衣', '色号', '制单人', '状态', 'QC时间',

<?php
echo WacModuleHelper::generateJqGridHiddenFields($invokeParams['objMainModuleTableFields']);
?>
                   '操作' ],
               colModel:[
                   {name:'id',index:'id',editable:false,hidden:true,width:30},
                   {name:'code',index:'code',sortable:false,editable:false,width:100,align:"left"},
                   {name:'production_order_code',index:'production_order_code',sortable:false,editable:false,width:100,align:"left"},
                   {name:'dispatch_order_code',index:'dispatch_order_code',sortable:false,editable:false,width:100,align:"left"},
                   {name:'roll_name',index:'roll_name',sortable:false,editable:false,width:100,align:"left"},
                   {name:'piece_length_name',index:'piece_length_name',sortable:false,editable:false,width:100,align:"left"},
                   {name:'wrapper_name',index:'wrapper_name',sortable:false,editable:false,width:100,align:"left"},
                   {name:'level',index:'level',sortable:false,editable:false,width:100,align:"left"},
                   {name:'standard',index:'standard',sortable:false,editable:false,width:100,align:"left"},
                   {name:'item1',index:'item1',sortable:false,editable:false,width:100,align:"left"},
                   {name:'item2',index:'item2',sortable:false,editable:false,width:100,align:"left"},
                   {name:'item3',index:'item3',sortable:false,editable:false,width:100,align:"left"},

                   {name:'maker_name',index:'maker_name',sortable:false,editable:false,width:100,align:"left"},
                   {name:'status_name',index:'status_name',sortable:false,editable:false,width:100,align:"left"},
                   {name:'qc_date',index:'qc_date',editable:false,align:"left",sorttype:'date',datefmt:'Y-m-d',width:150},


<?php
echo WacModuleHelper::generateJqGridHiddenFields($invokeParams['objMainModuleTableFields'], true);
?>

                 {
                     name:'act',
                     index:'act',
                     width:250,
                     editable:false,
                     sortable:false,
                     align:"center"
                 }
             ],
             jsonReader : {
                 root:"items",
                 page: "currentPage",
                 total: "totalPages",
                 records: "totalRecords",
                 userdata: "userdata",
                 id: "id",
                 repeatitems: false
             },
             rowNum:10,
             rowList:[10,20,30,40,50],
             sortname: 'id',
             sortorder: "desc",
             multiselect: false,
             viewrecords: true,
             pager: '#<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>',
             caption:"<?php echo $invokeParams['caption']; ?>列表",
             height: '100%',
             width: '100%',

             gridComplete: function(){
                 var ids = jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('getDataIDs');
                 var editUrl = BASE_URL + "<?php echo $invokeParams['moduleName']; ?>/edit";
                 var delUrl = BASE_URL + "<?php echo $invokeParams['moduleName']; ?>/delete";
                 for(var i=0;i < ids.length;i++){
                     var cl = ids[i];
<?php echo WacModuleHelper::generateListViewFormBtn($invokeParams['moduleName'],$invokeParams['attachName']);?>     // bv
<?php echo WacModuleHelper::generateListAuditFormBtn($invokeParams['moduleName'],$invokeParams['attachName']);?>    // ba
<?php echo WacModuleHelper::generateListAddSubFormBtn($invokeParams['subItemModuleName'],$invokeParams['attachName']);?>   // sa
<?php echo WacModuleHelper::generateListEditFormBtn($invokeParams['moduleName'],$invokeParams['attachName']);?>    // be
<?php echo WacModuleHelper::generateListDelFormBtn($invokeParams['moduleName'],$invokeParams['attachName']);?>    // de

<?php echo WacModuleHelper::generateListBtns($invokeParams['moduleName'], $invokeParams['subItemModuleName'], $invokeParams['attachName'], array('bv','ba','be','de'));?>
                                }
                            },

                            loadError : function(xhr,st,err){
                                alert("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
                            },

                            loadComplete: function()
                            {
                                //        wacDebugLog($.dump($("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('getGridParam', 'userData')));
                                //        wacDebugLog("loadComplete");
                                $(this).trigger("tabsload");   // inform tabs event listener
                            }

                        }); // grid end

                        jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('navGrid','#<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>',
                        {edit:false, add:false, del:false, search:true, refresh:true, view:false, position:"left"},
                        {afterSubmit: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackValidate, afterComplete: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackEdit},
                        {afterSubmit: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackValidate, afterComplete: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackAdd},
                        {afterComplete: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackDel},
                        {afterComplete: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackSearch},
                        {afterComplete: <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackView});

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackValidate(response, postdata){
                            //    wacDebugLog("callbackEdit");

                            wacAjaxData.response = eval('(' + response.responseText + ')');
                            //    wacDebugLog($.dump(wacAjaxData.response));
                            //    wacDebugLog($.dump(postdata));

                            if(wacAjaxData.response.userdata.status == wacOperationStatus.Succss)
                            {
                                return [true, "", ""];
                            }
                            else
                            {
                                return [false, wacAjaxData.response.userdata.error_info];
                            }
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackSave(response){
                            //    alert("callbackSave");
                            //    wacDebugLog("callbackSave");
                            //    wacDebugLog($.dump($("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('getGridParam', 'userData')));
                            //    wacDebugLog(response.responseText);
                            wacAjaxData.response = eval('(' + response.responseText + ')');
                            if(wacAjaxData.response.userdata.status == wacOperationStatus.Succss)
                            {
                                return true;
                            }
                            else
                            {
                                showTips(wacAjaxData.response.userdata.error_info);
                                return [false, wacAjaxData.response.userdata.error_info];
                            }
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackEdit()
                        {
                            //    alert("callbackEdit");
                            //    wacDebugLog("callbackEdit");
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackAdd()
                        {
                            //    alert("callbackAdd");
                            //    wacDebugLog("callbackAdd");
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackDel()
                        {
                            //    alert("callbackDel");
                            //    wacDebugLog("callbackDel");
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackSearch()
                        {
                            //    alert("callbackSearch");
                            //    wacDebugLog("callbackSearch");
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>CallbackView()
                        {
                            //    alert("callbackView");
                            //    wacDebugLog("callbackView");
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>FormValidate(postdata, formid)
                        {
                        }

                        function <?php echo $invokeParams['moduleName'].$invokeParams['attachName']; ?>FormValidateCallBack(jsonData)
                        {
                        }
                        //]]>
    </script>

    <br /><br />

</div>